var server="http://121.41.88.185:8080";
//var server="http://192.168.1.105:8090/jmax";
var cab="&callback=?";
//01 厦门  演示写死用
var areaId = "01";
//微信预付款订单编号
var payPreId = "";
//login sever config
var loginServer={
  fun:"/parkUser.action?login",
  telephone:"&telephone=",
  password:"&password=",
  getLoginReq:function(tel,pas){
    return server+this.fun+this.telephone+tel+this.password+pas+cab;
  }
}

//logout sever config
var logoutServer={
  fun:"/parkUser.action?logout&callback=?",
  telephone:"&telephone=",
  getLogoutReq:function(tel){
    return server+this.fun+this.telephone+tel+cab;
  }
}

//get validation code server config
var validationServer={
  fun:"/parkUser.action?getRegCode",
  telephone:"&telephone=",
  getValReq:function(tel){
    return server+this.fun+this.telephone+tel+cab;
  }
}

// register user server config
var registerServer={
  fun:"/parkUser.action?register",
  telephone:"&telephone=",
  password:"&password=",
  typet:"&type=2",
  regcode:"&regCode=",
  getRegisterReq:function(tel,pas,regcode){
    return server+this.fun+this.telephone+tel+this.password+pas+this.typet+this.regcode+regcode+cab;
  }
}

// update user infor server config
var updateInfServer={
  fun:"/parkUser.action?updateUser",
  telephone:"&telephone=",
  sex:"&sex=",
  namen:"&name=",
  carNo:"&carNo=",
  engineNo:"&engineNo=",
  getUpdateInfReq:function(tel,sex,na,cno,eno){
    return server+this.fun+this.telephone+tel+this.sex+sex+this.namen+na+this.carNo+cno+this.engineNo+eno+cab;
  }
}

//loading parking time and cost infor server config
var parkUserServer={
  fun:"/parkUser.action?loadBillDetail",
  aid:"&aid=",
  parkNo:"&parkNo=",
  getParkUserSerReq:function(ad,pn){
    return server+this.fun+this.aid+ad+this.parkNo+pn+cab;
  }
}

//
var createrOrderServer={
  fun:"/parkUser.action?createPreOrder",
  totalFee:"&totalFee=",
  parkNo:"&parkNo=",
  aid:"&aid=",
  telephone:"&telephone=",
  getCreaterOrderReq:function(tf,pn,tp,ac){
    return server+this.fun+this.aid+ac+this.totalFee+tf+this.parkNo+pn+this.telephone+tp+cab;
  }
}

var payOrderSuccessServer={
  fun:"/parkUser.action?paySuccessReturn",
  sysOrderNo:"&sysOrderNo=",
  payPreId:"&payPreId=",
  telephone:"&telephone=",
  returnPaySuccess:function(so,pi,tp){
    return server+this.fun+this.sysOrderNo+so+this.payPreId+pi+this.telephone+tp+cab;
  }
}

var vipOperationServer={
  fun:"/parkUser.action?vipOperation",
  aid:"&aid=",
  parkNo:"&parkNo=",
  operationType:"&operationType=",
  vipOperation:function(ad,pn,pt){
    return server+this.fun+this.aid+ad+this.parkNo+pn+this.operationType+pt+cab;
  }
}

function hideMainAFooter(){
  $("#mainfooter").hide();
  $("#mainheader").hide();
}

function showMainAFooter(){
  $("#mainfooter").show();
  $("#mainheader").show();
}

//pop base function
function popSucc(message){
  $.afui.popup({
    title: "",
    message: "<div style='text-align:center;'><img src='./img/messagesucc.png' />"
    +"<div style='padding:5px;'>"
    +message+"</div></div>",
    cancelOnly:true,
    cancelText:"确定",
    cancelClass:"button center alertButton"
  });
}

//faild message popup
function popFaild(message){
  $.afui.popup({
    title: "",
    message: "<div id='failedpop' style='text-align:center;'><img src='./img/messagefaild.png' />"
    +"<div style='padding:5px;'>"
    +message+"</div></div>",
    cancelOnly:true,
    cancelText:"确定",
    cancelClass:"button center alertButton"
  });
}

//choice message popup
function popChoice(message,doneCal,calCal){
  $.afui.popup({
    title: "",
    message: "<div style='text-align:center;'><img src='./img/messagefaild.png' />"
    +"<div style='padding:5px;'>"
    +message+"</div></div>",
    cancelOnly:false,
    doneText:"登录&注册",
    doneClass:"button choiceButton",
    cancelText:"取消",
    cancelClass:"button choiceButton",
    cancelCallback: function(){if(calCal){calCal()}},
    doneCallback: function(){doneCal()}
  });
}

function resetAll(){
  $("input").each(function(){
    $(this).val("");
  });
  $("#hours").html("00");
  $("#mints").html("00");
  $("#cost").html(" ￥0.00");
  $("#specailMenu").remove();
}

function isNumber(event, element) {
  if (event) {
    var max_chars = element.getAttribute("max").length;
    //console.log($(element).attr("cov"));
    var charCode = (event.which) ? event.which : event.keyCode;
    if(charCode==8){
      console.log($(element).val())
      if($(element).val()==""){
		  if($(element).attr("id")=="parkno2"){
		    $("#parkno1").focus();
		    var that=document.getElementById('parkno1');
		    setTimeout(function(){
		   	 var start = that.selectionStart,end = that.selectionEnd;
		   	 //console.log('d 1');
		   	 that.setSelectionRange(0,1);
		   	 if(start==1){
		   	   $(that).attr("cov","true");
		   	 }
		   	},20);
		  } 
		  if($(element).attr("id")=="parkno3"){
		    $("#parkno2").focus();
		    var that=document.getElementById('parkno2');
		    setTimeout(function(){
		   	 var start = that.selectionStart,end = that.selectionEnd;
		   	 //console.log('d 2');
		   	 that.setSelectionRange(0,1);
		   	 if(start==1){
		   	   $(that).attr("cov","true");
		   	 }
		   	},20);
		   }
		  if($(element).attr("id")=="parkno4"){
		    $("#parkno3").focus();
		    var that=document.getElementById('parkno3');
		    setTimeout(function(){
		   	 var start = that.selectionStart,end = that.selectionEnd;
		   	 //console.log('d 3');
		   	 that.setSelectionRange(0,1);
		   	 if(start==1){
		   	   $(that).attr("cov","true");
		   	 }
		   	},20);
			} 
		  if($(element).attr("id")=="parkno5"){
		    $("#parkno4").focus();
		    var that=document.getElementById('parkno4');
		    setTimeout(function(){
		   	 var start = that.selectionStart,end = that.selectionEnd;
		   	 //console.log('d 4');
		   	 that.setSelectionRange(0,1);
		   	 if(start==1){
		   	   $(that).attr("cov","true");
		   	 }
		   	},20);
		  }
		  if($(element).attr("id")=="parkno6"){
		    $("#parkno5").focus();
		    var that=document.getElementById('parkno5');
		    setTimeout(function(){
		   	 var start = that.selectionStart,end = that.selectionEnd;
		   	 //console.log('d 5');
		   	 that.setSelectionRange(0,1);
		   	 if(start==1){
		   	   $(that).attr("cov","true");
		   	 }
		   	},20);
		   } 
		   
      }else{
        $(element).val("");
      }
    }
    if (charCode != 190 && charCode > 31 &&
      (charCode < 48 || charCode > 57) &&
      (charCode < 96 || charCode > 105) &&
      (charCode < 37 || charCode > 40) &&
      charCode != 110 && charCode != 8 && charCode != 46 ) {
        return false;
    }
    if($(element).attr("cov")=="true"){
       $(element).attr("cov","false");
       $(element).val(String.fromCharCode(charCode));
       //nextInput(element);
    }
    if (element.value.length >= max_chars && charCode > 47) {
      return false;
    }else {
      return true;
    }
  }
}


function Carman(phoneno,namen,sex,carno,engno)
{
   this.phoneno=phoneno;
   this.name=namen;
   this.sex=sex;
   this.carno=carno;
   this.engno=engno;
}
Carman.prototype.getPhone=function(){
   return this.phoneno;
}

var Jsontest={
  attri1:15,
  attri2:"This is a string",
  attri3:function(){
    alert('this is a function');
  }
};
